var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/widgets/RootContainer.tsx
var RootContainer_exports = {};
__export(RootContainer_exports, {
  RootContainer: () => RootContainer
});
module.exports = __toCommonJS(RootContainer_exports);
var import_antd = require("antd");
var import_zh_CN = __toESM(require("antd/es/locale/zh_CN"));
var import_zh_cn = require("dayjs/locale/zh-cn");
var import_react = __toESM(require("react"));
var import_functionalComponent = require("../functionalComponent");
var import_util = require("../util");
var import_base = require("./base.less");
function useDefaultTheme() {
  const themeRef = (0, import_react.useRef)();
  (0, import_util.getCurrentWindow)()["__env__"] = "pc";
  (0, import_react.useLayoutEffect)(() => {
    var _a;
    if (!themeRef.current) {
      themeRef.current = { primaryColor: ((_a = import_util.defaultTheme.antdTheme.token) == null ? void 0 : _a.colorPrimary) || "#008EE0" };
      (0, import_util.initCustomThemeColor)(themeRef.current.primaryColor, { env: "pc", theme: import_util.defaultTheme });
    }
  }, []);
}
function RootContainer({ children, componentSize, spinProps, waterMark, configProvider }) {
  const [loadingState, setLoadingState] = (0, import_react.useState)({ spinning: false });
  const waterMarkProps = waterMark === true ? {} : { ...waterMark };
  const qkInfo = (0, import_util.useQkState)();
  useDefaultTheme();
  (0, import_react.useMemo)(() => {
    HTMLElement = new Function("return this")().HTMLElement;
    import_util.iup.registerExternal({
      getQianKun() {
        return qkInfo;
      }
    });
  }, [qkInfo]);
  (0, import_react.useEffect)(() => {
    import_util.iup.registerExternal({
      maskLoading(parmas = {}) {
        setLoadingState((p) => parmas ? { ...p, spinning: true, ...parmas } : { ...p, spinning: false });
      },
      getWaterMark(options = {}) {
        return waterMark && /* @__PURE__ */ import_react.default.createElement(import_util.WaterMark, { ...waterMark === true ? {} : waterMark, ...options });
      }
    });
  }, [waterMark]);
  return /* @__PURE__ */ import_react.default.createElement(
    import_antd.ConfigProvider,
    {
      getPopupContainer: import_util.getGlobalContainer,
      locale: import_zh_CN.default,
      componentSize,
      theme: import_util.defaultTheme.antdTheme,
      ...configProvider
    },
    /* @__PURE__ */ import_react.default.createElement(import_antd.App, { style: { height: "100%" } }, children, /* @__PURE__ */ import_react.default.createElement(import_functionalComponent.InjectModalCtx, null), /* @__PURE__ */ import_react.default.createElement(import_util.AppEntry, null), /* @__PURE__ */ import_react.default.createElement("div", { key: "loading" }, loadingState.spinning && /* @__PURE__ */ import_react.default.createElement(
      import_antd.Spin,
      {
        ...spinProps,
        ...loadingState,
        spinning: true,
        className: import_util.iup.classNames("iup-body-loading", loadingState.className)
      }
    )), waterMark && /* @__PURE__ */ import_react.default.createElement(import_util.WaterMark, { ...waterMarkProps }))
  );
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  RootContainer
});
